//I will go in NOIP
//by SIP zhangle from Class 7,Grade 7
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
inline void write(ll x)
{
    if(x<0)
    {
        putchar('-');
        x=(~x)+1;
    }
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
ll a[200005],n,b[200005],maxs,sum;
void dfs(ll x)
{
    if(x==n+1)
    {
        sum=0;
        for(ll i=2;i<=n;i++)
        {
            for(ll j=i-1;j>=1;j--)
            {
                if(b[i]==b[j])
                {
                    if(a[i]==a[j])sum+=a[i];
                    break;
                }
            }
        }
        maxs=max(maxs,sum);
        return;
    }
    b[x]=0;
    dfs(x+1);
    b[x]=1;
    dfs(x+1);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    ll T=1;
    T=read();
    while(T--)
    {
        n=read();
        for(ll i=1;i<=n;i++)a[i]=read();
        maxs=-1e18;
        dfs(1);
        write(maxs);
        putchar('\n');
    }
    return 0;
}
